  clear all
% import cv.*
sigma = 4;
threshold = 1.2;

load("origin.mat");
load("part.mat");
% origin=gpuArray(origin);
% part=gpuArray(part);
[n1,n]=size(part);
[n2,n]=size(origin);
% origin = gpuArray(origin);
% part1 = gpuArray(part1);

iter = 1;
for i=1:iter
    
    disp(i);
%      indexes = randperm(n1,n1);
%       origin_split=origin(indexes,:);

%      origin_split=origin(i*n2-n2+1:i*n2,:);
   
    origin_split=origin;
%     origin_split=part;
    [score,z,match_indexes1,match_indexes2]=EigenVectorMatch(part,origin_split,sigma,threshold);
    figure(1)
    %imshow('D:\Desktop\origin.png');
    clf;
    imshow('D:\Desktop\part.png')
    hold on
    plot(part(cell2mat(match_indexes1),1),part(cell2mat(match_indexes1),2),'go','LineWidth',2,'MarkerEdgeColor','red','MarkerFaceColor','red','MarkerSize',3)
     hold on
    figure(2)
    imshow('D:\Desktop\origin.png')
    hold on 
    plot(origin_split(cell2mat(match_indexes2),1),origin_split(cell2mat(match_indexes2),2),'go','LineWidth',2,'MarkerEdgeColor','red','MarkerFaceColor','red','MarkerSize',3)
    
end


% 
% [n1,n2]=size(match_point_index);
% cx1 = zeros(n2);
% cy1 = zeros(n2);
% cx2 = zeros(n2);
% cy2 = zeros(n2);
% for i=1:n2
%     cx1(i)=match_point_index{i}(1);
%     cy1(i)=match_point_index{i}(2);
%     cx2(i)=match_point_index{i}(3);
%     cy2(i)=match_point_index{i}(4);
% end
% 
% figure(1)
% imshow('D:\Desktop\origin.png');
% hold on
% plot(cx1,cy1,'go','LineWidth',2,'MarkerEdgeColor','red','MarkerFaceColor','red','MarkerSize',3)
% hold on 
% 
% figure(2)
% imshow('D:\Desktop\part.png')
% hold on
% plot(cx2,cy2,'cs','LineWidth',2,'MarkerEdgeColor','red','MarkerFaceColor','red','MarkerSize',3)
% hold on
% axis([0 12 0 32])
% grid on



